package org.liushengpei.com.config;

import org.liushengpei.com.intercept.LoginIntercept;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

import javax.annotation.Resource;

/**
 * 拦截器配置
 */
@Configuration
public class InterceptConfig extends WebMvcConfigurationSupport {

    @Resource
    private StringRedisTemplate stringRedisTemplate;

    /**
     * 配置拦截规则
     */
    @Override
    protected void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new LoginIntercept(stringRedisTemplate))
                .excludePathPatterns("/user/userLogin",
                        "/user/userRegister",
                        "/user/forgetPassword",
                        "/user/updatePassword"); //放行路径
    }
}
